﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Aj.Core;

public partial class news : PageBase
{
    //新闻资讯
    protected DataSet newsPicDs = null;
    protected List<DataRow> newsDrs = new List<DataRow>();

    protected DataSet videoPicDs = null;
    protected DataSet videoDs = null;

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        try
        {
            // 新闻资讯
            //   带图片
            newsPicDs = CustomQuery.Article_GetArticlePicByCId(3, Utility.NewsCid);
            string notInNewsIds = "";
            if (newsPicDs != null && newsPicDs.Tables.Count > 0 && newsPicDs.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in newsPicDs.Tables[0].Rows)
                {
                    notInNewsIds += (notInNewsIds.IsNotNullAndEmpty() ? "," : "") + dr["A_Id"].ToString();
                }
            }
            //  不带图片
            int ortherNewsCount = 11;
            DataSet hotNewsDs = CustomQuery.Article_GetArticleNewsByCId(5, Utility.NewsCid, " and A_Top like '%A%'", notInNewsIds);
            if (hotNewsDs != null && hotNewsDs.Tables.Count > 0 && hotNewsDs.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in hotNewsDs.Tables[0].Rows)
                {
                    notInNewsIds += (notInNewsIds.IsNotNullAndEmpty() ? "," : "") + dr["A_Id"].ToString();
                    ortherNewsCount--;
                    newsDrs.Add(dr);
                }
            }
            DataSet newsDs = CustomQuery.Article_GetArticleNewsByCId(ortherNewsCount, Utility.NewsCid, notInNewsIds);
            if (newsDs != null && newsDs.Tables.Count > 0 && newsDs.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in newsDs.Tables[0].Rows)
                {
                    ortherNewsCount--;
                    newsDrs.Add(dr);
                }
            }

            // 视频集锦
            //   带图片
            videoPicDs = CustomQuery.Article_GetArticlePicByCId(3, Utility.VodeoCid);
            string notInVideoIds = "";
            if (videoPicDs != null && videoPicDs.Tables.Count > 0 && videoPicDs.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in videoPicDs.Tables[0].Rows)
                {
                    notInVideoIds += (notInVideoIds.IsNotNullAndEmpty() ? "," : "") + dr["A_Id"].ToString();
                }
            }
            //  不带图片
            videoDs = CustomQuery.Article_GetArticleNewsByCId(4, Utility.VodeoCid, notInVideoIds);
        }
        catch (Exception ex)
        {
            Utility.WriteErrorLog("news", ex);
        }
    }
}